package com.gitee.huanminabc.jtimerwheel.mode;

import com.gitee.huanminabc.jtimerwheel.base.TimeSlotInfo;
import com.gitee.huanminabc.jtimerwheel.base.TimerResolverCore;
import com.gitee.huanminabc.jtimerwheel.base.TimerWheelModeMethod;
import com.gitee.huanminabc.jtimerwheel.utils.TimerWheelDateUtil;

/**
 * 简要描述
 *
 * @Author: huanmin
 * @Date: 2022/12/1 1:21
 * @Version: 1.0
 * @Description: 文件作用详细描述....
 */
public class TimeEndMode implements TimerWheelModeMethod {
    @Override
    public void modeMethod(TimeSlotInfo item, int seat, TimerResolverCore timerResolver) {
        if (seat == 0) { //秒数
            timerResolver.timestamp= timerResolver.timestamp+59;
        } else if (seat == 1) { //分钟数(如果当前时间是59秒,则返回下一分钟的59秒)
            timerResolver.timestamp=  TimerWheelDateUtil.getDateNextMinuteEnd(TimerWheelDateUtil.secondTurnDate(timerResolver.timestamp)) ;
        } else if (seat == 2) { //小时数
            timerResolver.timestamp=  TimerWheelDateUtil.getDateNextDayEnd(TimerWheelDateUtil.secondTurnDate(timerResolver.timestamp)) ;
        } else if (seat == 3) { //天数
            timerResolver.timestamp=  TimerWheelDateUtil.getDateNextDayEnd(TimerWheelDateUtil.secondTurnDate(timerResolver.timestamp)) ;
        } else if (seat == 4) { //星期数(周末开始时间)
            timerResolver.timestamp=  TimerWheelDateUtil.getDateNextWeekEnd(TimerWheelDateUtil.secondTurnDate(timerResolver.timestamp));
        } else if (seat == 5) { //月数
            timerResolver.timestamp=  TimerWheelDateUtil.getDateNextMonthEnd(TimerWheelDateUtil.secondTurnDate(timerResolver.timestamp)) ;
        } else if (seat == 6) { //年数
            timerResolver.timestamp=  TimerWheelDateUtil.getDateNextYearEnd(TimerWheelDateUtil.secondTurnDate(timerResolver.timestamp)) ;
        }
    }
}
